package com.wngbms.netty.book._06endec._01;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class Byte2IntegerReplayDecoder extends ReplayingDecoder<Integer> {

    /**
     * class io.netty.channel.DefaultChannelHandlerContext
     * class io.netty.handler.codec.ReplayingDecoderByteBuf
     * class io.netty.handler.codec.CodecOutputList
     * @param ctx
     * @param in
     * @param out
     * @throws Exception
     */
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
        int i = in.readInt();
//        log.info("decode{}", i);
        out.add(i);
    }
}
